<template>
  <div>
    <div>
      <el-table
          row-key="id"
          :data="AwardMessage"
          border style="width: 100%"
          :header-cell-style="{'text-align':'center'}"
          :cell-style="{'text-align':'center'}">


        <el-table-column prop="awardName" label="奖项名称" width="500"/>
        <el-table-column prop="awardData" label="获奖日期" width="180"/>
        <el-table-column prop="awardLevel" label="奖项等级" width="120" />
        <el-table-column prop="teacher" label="指导老师" width="120" />

        <el-table-column align="center" fixed="right" prop="operate" label="操作" width="150">
          <template v-slot="scope">
            <el-button
                size="small"
                type="primary" icon="Edit"
                @click="detailedInformation1(scope)"
            >查看详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-dialog
        v-model="detailedInformation"
        :close-on-click-modal="false"
        title="学生详细信息"
        width="850px">
      <information v-if="detailedInformation" ref="dialog"/>
    </el-dialog>
    <div class="footer">
      <el-config-provider :locale="locale">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[15, 30 , 60 ,  100 , 200 , 500 , 1000 , 2000 , 5000]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </el-config-provider>
    </div>
  </div>
</template>

<script>
import request from "@/util/request.js";
import Information from "@/template/Information.vue";
import search from "@element-plus/icons/lib/Search.js";

export default {
  components: {Information},
  computed: {
    search() {
      return search
    }
  },

  data() {
    return {
      detailedInformation: false,
      AwardMessage: [],
      information: {},
      NameOrStudentAccount: "",
      command: '全部',
      pageNum: 1, //页码
      pageSize: 15,  //页长
      total: 0,  //总表长
      instructorNameAll: [],
      instructorName: [],
      text :"" ,
      value: "",
    };
  },
  //初始化加载
  created() {
    console.log("初始化加载方法");
    this.getAllAwardMessage(); //加载所有奖惩信息
  },
  methods: {
    detailedInformation1(scope) {
      // this.information = scope.row
      // this.detailedInformation = true
      // window.getTemplateData = (callback) => {
      //   this.getTemplateData(callback);
      // }
    },
    getTemplateData(callback) {
      callback(this.information);
    },


    //获取当前用户奖惩信息
    getAllAwardMessage() {
      request.get("/info_award/getOneByAccountNo?accountNo=" +JSON.parse(localStorage.getItem('user')).accountNo).then(res => {
        if (res.data.code === '200') {
          console.log(res.data.data)
          this.AwardMessage = res.data.data
        } else {
          console.log("服务端错误")
        }
      })
    },
    instructorFilterHandler(value, row) {
      console.log(row.instructorName)
      return row.instructorName === value;
    },
    //表尾分页
    handleSizeChange(val) {
      this.pageSize = val;
      this.getAllNoticeType();
    },
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getAllNoticeType();
    },
  }
};

</script>


<style scoped>
table {
  border-collapse: collapse;
  text-align: center;
  vertical-align: middle;
  font-family: "宋体", SimSun;
}

th, td {
  border: 1px solid black;
  padding: 10px 0;
  font-family: "Times New Roman", Times, serif;
}

</style>